package com.synjones.visitor;

import android.content.Context;

import com.synjones.face.camera.FaceHelper;
import com.synjones.idcard.IDCard;
import com.synjones.idcardusb_reader.IdCardHelper;

public class CardInfoPresenter implements CardInfoContract.Presenter {

    private CardInfoContract.View view;
    private IdCardHelper idCardHelper;
    private FaceHelper faceHelper;

    public CardInfoPresenter(CardInfoContract.View view,FaceHelper faceHelper) {
        this.view = view;
        this.faceHelper = faceHelper;
        idCardHelper = new IdCardHelper((Context) view);
    }


    @Override
    public void start() {
        idCardHelper.open(new IdCardHelper.OnReadIdCard() {
            @Override
            public void onReadIdCard(IDCard idCard) {
                view.showIdCardInfo(idCard);
                if (faceHelper.isInitSuccess()) {
//                    float score = faceHelper.compareIdcard(idCard.getPhoto());
//                    view.showCompareInfo(score);
                }
            }
        });
    }

    @Override
    public void release() {
        idCardHelper.close();
    }
}
